package com.yl.ydk.ui.activity

import android.content.Intent
import android.view.View
import android.widget.TextView
import androidx.core.widget.NestedScrollView
import com.yl.ydk.R
import com.yl.ydk.base.BaseActivity
import com.yl.ydk.presenter.contract.DiseaseDetailActivityContract
import com.yl.ydk.presenter.impl.DiseaseDetailActivityImpl
import com.yl.ydk.view.myViewPager
import com.blankj.utilcode.utils.ToastUtils
import com.flyco.tablayout.SlidingTabLayout
import kotlinx.android.synthetic.main.activity_disease_detail.*
import kotlinx.android.synthetic.main.roob_bar.*

class DiseaseDetailActivity : BaseActivity(), View.OnClickListener,
    DiseaseDetailActivityContract.View {


    private val mPresenter = DiseaseDetailActivityImpl()

    override fun getLayoutId(): Int = R.layout.activity_disease_detail

    override fun attachView() {
        mPresenter.attachView(this)
    }

    override fun detachView() {
        mPresenter.detachView()
    }

    override fun initView() {
        tvTitle.text = "常见疾病"
        rlSearch.visibility = View.VISIBLE
        rlBack.setOnClickListener(this)
        rlSearch.setOnClickListener(this)

        intent.getStringExtra("data")?.let {
            mPresenter.getGetDiseaseDetail(this, "name", it)
        }

    }

    override fun onClick(v: View?) {
        when (v?.id) {
            R.id.rlBack -> {
                finish()
            }
            R.id.rlSearch -> {
                startActivityIn(Intent(this, DiseaseSearchActivity::class.java), this)
                finish()
            }
        }
    }

    override fun getActivity(): DiseaseDetailActivity = this

    override fun getViewPager(): myViewPager? = vpContext

    override fun getSlidingTabLayout(): SlidingTabLayout? = tlTab

    override fun getDeptTextView(): TextView? = tvDept

    override fun getNameTextView(): TextView? = tvName

    override fun getNestedScrollView(): NestedScrollView? = nsv

    override fun showError(message: String?) {
        ToastUtils.showLongToastSafe(message)
    }

}